package cn.hp.crm.util;

import com.alibaba.fastjson.JSON;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

// 将java对象转换成json对象
public class JsonForServlet {

//    将json数据传给页面
    public static void transferData(HttpServletResponse response, ResultData data ){
//        response.setContentType("text/json;charset=utf-8");
        String s = JSON.toJSONString(data);
//        JSONObject objects = JSON.parseObject(s);
        try {
            response.getWriter().println(s);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
